////////////////////////////////////////////////////////////////
// filename: level.cpp
// description: code for our level handler
// autor: Jay Tomten (jaytomten@gmail.com)
// notes:

// namespace

// defines

// includes
#include <SDL/SDL.h>
#include <iostream>
#include "object.h"
#include "world.h"
#include "story.h"
#include "particle.h"
#include "character.h"
#include "level.h"

// globals

////////////////////////////////////////////////////////////////
// constructor
Level::Level() {

    // use Init()

}

////////////////////////////////////////////////////////////////
// destructor
Level::~Level() {

    // delete all the objects in the list.... memory leak here!!!
    delete p1;
    delete p2;

}

////////////////////////////////////////////////////////////////
// Init() - loat the right level
bool Level::Init(int lev, List *gameList, List *p1List, List *p2List, int smooth) {

    // get all our lists
    l = gameList;
    p1 = p1List;
    p2 = p2List;
    level = lev;
    stage = 0;

    // generic objects for loading into the lists
    World *a;
    Particle *b;
    Character *c;
    Story *d;

    // start this way to long bit of code, dynamic loading might be a little sexier/slower
    switch(level) {
    case LEVEL_STORY_1:
        cout << "Loading story level 1... ";
        music.PlayMusic(MUSIC_STORY);
        d = new Story(STORY_1, 0.0f, 0.0f, 0.0f);
        l->InsertBack(d);
        break;

    case LEVEL_STORY_2:
        cout << "Loading story level 3... ";
        music.PlayMusic(MUSIC_STORY);
        d = new Story(STORY_2, 0.0f, 0.0f, 0.0f);
        l->InsertBack(d);
        break;

    case LEVEL_STORY_3:
        cout << "Loading story level 3... ";
        music.PlayMusic(MUSIC_STORY);
        d = new Story(STORY_3, 0.0f, 0.0f, 0.0f);
        l->InsertBack(d);
        break;

    case LEVEL_STORY_4:
        cout << "Loading story level 4... ";
        music.PlayMusic(MUSIC_STORY);
        d = new Story(STORY_4, 0.0f, 0.0f, 0.0f);
        l->InsertBack(d);
        break;

    case LEVEL_STORY_5:
        cout << "Loading story level 5... ";
        music.PlayMusic(MUSIC_STORY);
        d = new Story(STORY_5, 0.0f, 0.0f, 0.0f);
        l->InsertBack(d);
        break;

    case LEVEL_STORY_6:
        cout << "Loading story level 6... ";
        music.PlayMusic(MUSIC_STORY);
        d = new Story(STORY_6, 0.0f, 0.0f, 0.0f);
        l->InsertBack(d);
        break;

    case LEVEL_STORY_7:
        cout << "Loading story level 7... ";
        music.PlayMusic(MUSIC_STORY);
        d = new Story(STORY_7, 0.0f, 0.0f, 0.0f);
        l->InsertBack(d);
        break;

    case LEVEL_STORY_8:
        cout << "Loading story level 8... ";
        music.PlayMusic(MUSIC_STORY);
        d = new Story(STORY_8, 0.0f, 0.0f, 0.0f);
        l->InsertBack(d);
        break;

    case LEVEL_DEMO:
        cout << "Loading demo level... ";
        if(stage <= 0) {
            music.PlayMusic(MUSIC_MENU);
            stage = 1;
            a = new World(WORLD_LAND, 0.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            if(smooth > -1) b = new Particle(PARTICLE_RAIN, 0.0f, 40.0f, 0.0f);
            if(smooth > -1) l->InsertBack(b);
            a = new World(WORLD_BUILDING_1, -93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -35.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 335.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -80.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -65.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 80.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 65.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUNKER, 98.6, 0.0f, 0.0f);
            p2->InsertBack(a);
            a = new World(WORLD_BUNKER, -100.0f, 0.0f, 0.0f);
            p1->InsertBack(a);
            c = new Character(CHAR_INFANTRY, -90.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 90.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_INFANTRY, -83.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 83.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            if(smooth > -1) a = new World(WORLD_CLOUDS_1, -180.0f, 0.0f, -20.0f);
            if(smooth > -1) l->InsertFront(a);
            a = new World(WORLD_SKY_4, -180.0f, 0.0f, -50.0f);
            l->InsertFront(a);
            a = new World(WORLD_GROUND_1, -180.0f, 0.0f, 0.0f);
            l->InsertFront(a);
            cout << "success.\n";
        }
        break;
    case LEVEL_1:
	cout << "Loading level 1... ";
        if(stage <= 0) {
            music.PlayMusic(MUSIC_1);
            stage = 1;
            if(smooth > -1) b = new Particle(PARTICLE_SNOW, 0.0f, 40.0f, 0.0f);
            if(smooth > -1) l->InsertBack(b);
            a = new World(WORLD_LAND, 0.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -90.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -40.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 40.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 90.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -10.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 10.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUNKER, 98.6, 0.0f, 0.0f);
            p2->InsertBack(a);
            a = new World(WORLD_BUNKER, -100.0f, 0.0f, 0.0f);
            p1->InsertBack(a);
            c = new Character(CHAR_INFANTRY, -80.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 80.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            if(smooth > -1) a = new World(WORLD_CLOUDS_1, -180.0f, 0.0f, -20.0f);
            if(smooth > -1) l->InsertFront(a);
            a = new World(WORLD_SKY_1, -180.0f, 0.0f, -50.0f);
            l->InsertFront(a);
            a = new World(WORLD_GROUND_1, -180.0f, 0.0f, 0.0f);
            l->InsertFront(a);
            cout << "success.\n";
        }
        break;
    case LEVEL_2:
	cout << "Loading level 2... ";
        if(stage <= 0) {
            music.PlayMusic(MUSIC_2);
            stage = 1;
            if(smooth > -1) b = new Particle(PARTICLE_DUST, 150.0f, 1.0f, 1.0f);
            if(smooth > -1) l->InsertBack(b);
            a = new World(WORLD_LAND, 0.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -35.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 335.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUNKER, 98.6, 0.0f, 0.0f);
            p2->InsertBack(a);
            a = new World(WORLD_BUNKER, -100.0f, 0.0f, 0.0f);
            p1->InsertBack(a);
            c = new Character(CHAR_INFANTRY, -90.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 90.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_INFANTRY, -83.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 83.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            a = new World(WORLD_SKY_2, -180.0f, 0.0f, -50.0f);
            l->InsertFront(a);
            a = new World(WORLD_GROUND_1, -180.0f, 0.0f, 0.0f);
            l->InsertFront(a);
            cout << "success.\n";
        }
        break;
    case LEVEL_3:
	cout << "Loading level 3... ";
        if(stage <= 0) {
            music.PlayMusic(MUSIC_3);
            stage = 1;
            if(smooth > -1) b = new Particle(PARTICLE_SNOW, 0.0f, 40.0f, 0.0f);
            if(smooth > -1) l->InsertBack(b);
            a = new World(WORLD_LAND, 0.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -35.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 335.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUNKER, 98.6, 0.0f, 0.0f);
            p2->InsertBack(a);
            a = new World(WORLD_BUNKER, -100.0f, 0.0f, 0.0f);
            p1->InsertBack(a);
            c = new Character(CHAR_INFANTRY, -90.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 90.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_INFANTRY, -83.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 83.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            a = new World(WORLD_SKY_3, -180.0f, 0.0f, -50.0f);
            l->InsertFront(a);
            a = new World(WORLD_GROUND_1, -180.0f, 0.0f, 0.0f);
            l->InsertFront(a);
            cout << "success.\n";
        }
        break;
    case LEVEL_4:
	cout << "Loading level 4... ";
        if(stage <= 0) {
            music.PlayMusic(MUSIC_4);
            stage = 1;
            if(smooth > -1) b = new Particle(PARTICLE_RAIN, 0.0f, 40.0f, 0.0f);
            if(smooth > -1) l->InsertBack(b);
            a = new World(WORLD_LAND, 0.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -35.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 335.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUNKER, 98.6, 0.0f, 0.0f);
            p2->InsertBack(a);
            a = new World(WORLD_BUNKER, -100.0f, 0.0f, 0.0f);
            p1->InsertBack(a);
            c = new Character(CHAR_INFANTRY, -90.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 90.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_INFANTRY, -83.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 83.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            a = new World(WORLD_SKY_4, -180.0f, 0.0f, -50.0f);
            l->InsertFront(a);
            a = new World(WORLD_GROUND_1, -180.0f, 0.0f, 0.0f);
            l->InsertFront(a);
            cout << "success.\n";
        }
        break;
    case LEVEL_5:
	    cout << "Loading level 5... ";
        if(stage <= 0) {
            music.PlayMusic(MUSIC_5);
            stage = 1;
            if(smooth > -1) b = new Particle(PARTICLE_SNOW, 0.0f, 40.0f, 0.0f);
            if(smooth > -1) l->InsertBack(b);
            a = new World(WORLD_LAND, 0.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -90.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -40.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 40.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 90.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -10.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 10.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUNKER, 98.6, 0.0f, 0.0f);
            p2->InsertBack(a);
            a = new World(WORLD_BUNKER, -100.0f, 0.0f, 0.0f);
            p1->InsertBack(a);
            c = new Character(CHAR_INFANTRY, -80.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 80.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            if(smooth > -1) a = new World(WORLD_CLOUDS_1, -180.0f, 0.0f, -20.0f);
            if(smooth > -1) l->InsertFront(a);
            a = new World(WORLD_SKY_1, -180.0f, 0.0f, -50.0f);
            l->InsertFront(a);
            a = new World(WORLD_GROUND_1, -180.0f, 0.0f, 0.0f);
            l->InsertFront(a);
            cout << "success.\n";
        }
        break;
    case LEVEL_6:
	    cout << "Loading level 6... ";
        if(stage <= 0) {
            music.PlayMusic(MUSIC_6);
            stage = 1;
            if(smooth > -1) b = new Particle(PARTICLE_DUST, 150.0f, 1.0f, 1.0f);
            if(smooth > -1) l->InsertBack(b);
            a = new World(WORLD_LAND, 0.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -35.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 335.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUNKER, 98.6, 0.0f, 0.0f);
            p2->InsertBack(a);
            a = new World(WORLD_BUNKER, -100.0f, 0.0f, 0.0f);
            p1->InsertBack(a);
            c = new Character(CHAR_INFANTRY, -90.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 90.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_INFANTRY, -83.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 83.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            a = new World(WORLD_SKY_2, -180.0f, 0.0f, -50.0f);
            l->InsertFront(a);
            a = new World(WORLD_GROUND_1, -180.0f, 0.0f, 0.0f);
            l->InsertFront(a);
            cout << "success.\n";
        }
        break;
    case LEVEL_7:
	    cout << "Loading level 7... ";
        if(stage <= 0) {
            music.PlayMusic(MUSIC_7);
            stage = 1;
            if(smooth > -1) b = new Particle(PARTICLE_SNOW, 0.0f, 40.0f, 0.0f);
            if(smooth > -1) l->InsertBack(b);
            a = new World(WORLD_LAND, 0.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -35.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 335.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUNKER, 98.6, 0.0f, 0.0f);
            p2->InsertBack(a);
            a = new World(WORLD_BUNKER, -100.0f, 0.0f, 0.0f);
            p1->InsertBack(a);
            c = new Character(CHAR_INFANTRY, -90.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 90.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_INFANTRY, -83.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 83.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            a = new World(WORLD_SKY_3, -180.0f, 0.0f, -50.0f);
            l->InsertFront(a);
            a = new World(WORLD_GROUND_1, -180.0f, 0.0f, 0.0f);
            l->InsertFront(a);
            cout << "success.\n";
        }
        break;
    case LEVEL_8:
	    cout << "Loading level 8... ";
        if(stage <= 0) {
            music.PlayMusic(MUSIC_8);
            stage = 1;
            if(smooth > -1) b = new Particle(PARTICLE_RAIN, 0.0f, 40.0f, 0.0f);
            if(smooth > -1) l->InsertBack(b);
            a = new World(WORLD_LAND, 0.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -35.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 335.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 93.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_1, -15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_2, -30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_3, 15.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUILDING_4, 30.0f, 0.0f, 0.0f);
            l->InsertBack(a);
            a = new World(WORLD_BUNKER, 98.6, 0.0f, 0.0f);
            p2->InsertBack(a);
            a = new World(WORLD_BUNKER, -100.0f, 0.0f, 0.0f);
            p1->InsertBack(a);
            c = new Character(CHAR_INFANTRY, -90.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 90.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_INFANTRY, -83.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
            c = new Character(CHAR_INFANTRY, 83.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            a = new World(WORLD_SKY_4, -180.0f, 0.0f, -50.0f);
            l->InsertFront(a);
            a = new World(WORLD_GROUND_1, -180.0f, 0.0f, 0.0f);
            l->InsertFront(a);
            cout << "success.\n";
        }
        break;
    default:
        break;
    }

    return true;

}

////////////////////////////////////////////////////////////////
// Update() - process the levels events
bool Level::Update(float d) {

    // update this current levels time and phase
    time +=  d;
    phase += d;

    Character *c;

    // simple switch for adding stuff to levels, consider more advance AI!!!!!
    switch(level) {
    case LEVEL_DEMO:
        if(stage <= 1 && phase > 1.0f) {
            stage = 2;
            c = new Character(CHAR_INFANTRY, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 2 && phase > 4.0f) {
            stage = 3;
            c = new Character(CHAR_ENGINEER, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_ENGINEER, -99.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
        }
        if(stage <= 3 && phase > 7.0f) {
            stage = 4;
            c = new Character(CHAR_MEDIC, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_MEDIC, -99.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
        }
        if(stage <= 4 && phase > 10.0f) {
            stage = 5;
            c = new Character(CHAR_EOD, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_SF, -99.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
        }
        if(stage <= 5 && phase > 13.0f) {
            stage = 1;
            phase = 0.0;
            c = new Character(CHAR_SF, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
            c = new Character(CHAR_EOD, -99.0f, 0.0f, 0.0f);
            p1->InsertBack(c);
        }
        break;
    case LEVEL_1:
        if(stage <= 1 && phase > 10.0f) {
            stage = 2;
            c = new Character(CHAR_INFANTRY, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 2 && phase > 20.0f) {
            stage = 3;
            c = new Character(CHAR_ENGINEER, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 3 && phase > 30.0f) {
            stage = 4;
            c = new Character(CHAR_MEDIC, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 4 && phase > 40.0f) {
            stage = 5;
            c = new Character(CHAR_EOD, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 5 && phase > 50.0f) {
            stage = 1;
            phase = 0.0;
            c = new Character(CHAR_SF, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        break;
    case LEVEL_2:
        if(stage <= 1 && phase > 9.0f) {
            stage = 2;
            c = new Character(CHAR_ENGINEER, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 2 && phase > 18.0f) {
            stage = 3;
            c = new Character(CHAR_INFANTRY, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 3 && phase > 27.0f) {
            stage = 4;
            c = new Character(CHAR_MEDIC, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 4 && phase > 36.0f) {
            stage = 5;
            c = new Character(CHAR_EOD, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 5 && phase > 45.0f) {
            stage = 1;
            phase = 0.0;
            c = new Character(CHAR_SF, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        break;
    case LEVEL_3:
        if(stage <= 1 && phase > 9.0f) {
            stage = 2;
            c = new Character(CHAR_ENGINEER, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 2 && phase > 18.0f) {
            stage = 3;
            c = new Character(CHAR_INFANTRY, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 3 && phase > 27.0f) {
            stage = 4;
            c = new Character(CHAR_MEDIC, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 4 && phase > 36.0f) {
            stage = 5;
            c = new Character(CHAR_EOD, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 5 && phase > 45.0f) {
            stage = 1;
            phase = 0.0;
            c = new Character(CHAR_SF, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        break;
    case LEVEL_4:
        if(stage <= 1 && phase > 9.0f) {
            stage = 2;
            c = new Character(CHAR_ENGINEER, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 2 && phase > 18.0f) {
            stage = 3;
            c = new Character(CHAR_INFANTRY, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 3 && phase > 27.0f) {
            stage = 4;
            c = new Character(CHAR_MEDIC, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 4 && phase > 36.0f) {
            stage = 5;
            c = new Character(CHAR_EOD, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 5 && phase > 45.0f) {
            stage = 1;
            phase = 0.0;
            c = new Character(CHAR_SF, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        break;
    case LEVEL_5:
        if(stage <= 1 && phase > 10.0f) {
            stage = 2;
            c = new Character(CHAR_INFANTRY, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 2 && phase > 20.0f) {
            stage = 3;
            c = new Character(CHAR_ENGINEER, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 3 && phase > 30.0f) {
            stage = 4;
            c = new Character(CHAR_MEDIC, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 4 && phase > 40.0f) {
            stage = 5;
            c = new Character(CHAR_EOD, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 5 && phase > 50.0f) {
            stage = 1;
            phase = 0.0;
            c = new Character(CHAR_SF, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        break;
    case LEVEL_6:
        if(stage <= 1 && phase > 9.0f) {
            stage = 2;
            c = new Character(CHAR_ENGINEER, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 2 && phase > 18.0f) {
            stage = 3;
            c = new Character(CHAR_INFANTRY, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 3 && phase > 27.0f) {
            stage = 4;
            c = new Character(CHAR_MEDIC, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 4 && phase > 36.0f) {
            stage = 5;
            c = new Character(CHAR_EOD, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 5 && phase > 45.0f) {
            stage = 1;
            phase = 0.0;
            c = new Character(CHAR_SF, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        break;
    case LEVEL_7:
        if(stage <= 1 && phase > 9.0f) {
            stage = 2;
            c = new Character(CHAR_ENGINEER, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 2 && phase > 18.0f) {
            stage = 3;
            c = new Character(CHAR_INFANTRY, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 3 && phase > 27.0f) {
            stage = 4;
            c = new Character(CHAR_MEDIC, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 4 && phase > 36.0f) {
            stage = 5;
            c = new Character(CHAR_EOD, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 5 && phase > 45.0f) {
            stage = 1;
            phase = 0.0;
            c = new Character(CHAR_SF, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        break;
    case LEVEL_8:
        if(stage <= 1 && phase > 9.0f) {
            stage = 2;
            c = new Character(CHAR_ENGINEER, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 2 && phase > 18.0f) {
            stage = 3;
            c = new Character(CHAR_INFANTRY, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 3 && phase > 27.0f) {
            stage = 4;
            c = new Character(CHAR_MEDIC, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 4 && phase > 36.0f) {
            stage = 5;
            c = new Character(CHAR_EOD, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        if(stage <= 5 && phase > 45.0f) {
            stage = 1;
            phase = 0.0;
            c = new Character(CHAR_SF, 99.0f, 0.0f, 0.0f);
            p2->InsertBack(c);
        }
        break;
    default:
        return false;
        break;
    }

    return true;

}
